package com.yonyou.cyxdms.sysAuth.service.controller.notification;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.bean.dto.framework.RestResultResponse;
import com.yonyou.cyx.framework.controller.base.BaseController;
import com.yonyou.cyx.framework.util.bean.ApplicationContextHelper;
import com.yonyou.cyx.function.exception.ServiceBizException;
import com.yonyou.cyx.function.utils.common.StringUtils;
import com.yonyou.cyxdms.framework.bean.dto.user_info.LoginInfoDto;
import com.yonyou.cyxdms.sysAuth.service.constants.CommonConstants;
import com.yonyou.cyxdms.sysAuth.service.constants.SysAuthDictCodeConstants;
import com.yonyou.cyxdms.sysAuth.service.dto.notification.NotificationDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.notification.NotificationFeedbackDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.notification.NotificationInfoDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.notification.TextNotifyDto;
import com.yonyou.cyxdms.sysAuth.service.feign.CustomerService;
import com.yonyou.cyxdms.sysAuth.service.feign.FileServiceClient;
import com.yonyou.cyxdms.sysAuth.service.service.dealerchannel.DealerChannelService;
import com.yonyou.cyxdms.sysAuth.service.service.notification.NotificationFeedbackService;
import com.yonyou.cyxdms.sysAuth.service.service.notification.NotificationService;
import com.yonyou.cyxdms.sysAuth.service.service.org.OrgService;
import com.yonyou.cyxdms.sysAuth.service.service.role.RoleService;
import com.yonyou.cyxdms.sysAuth.service.vo.notification.AddNotificationVO;
import com.yonyou.cyxdms.sysAuth.service.vo.org.OrgVO;
import com.yonyou.cyxdms.sysAuth.service.vo.role.RolePageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author adu
 * @since 2019-10-14
 */
@RestController
@RequestMapping("/notification")
@Api(value = "通知通告", tags = {"通知通告维护"})
public class NotificationController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(NotificationController.class);

    @Autowired
    public NotificationService notificationService;
    @Autowired
    public NotificationFeedbackService notificationFeedbackService;
    @Autowired
    public FileServiceClient fileServiceClient;
    @Autowired
    CustomerService c;
    @Autowired
    private RoleService roleService;
    @Autowired
    private DealerChannelService dealerChannelService;

    @Autowired
    public OrgService orgService;

    /**
     * 分页查询数据
     *
     * @return com.baomidou.mybatisplus.core.metadata.IPage 分页对象
     * @author chengliang
     * @since 2019-09-05
     */
    @ResponseBody
    @GetMapping
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "通知通告分页获取数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public IPage<Map<String, Object>> getList(@RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Map<String, Object> queryCondition = new HashMap<>();
        queryCondition.put("appId", loginInfo.getAppId());
        Page<Map<String, Object>> page = new Page<>(currentPage, pageSize);
        return notificationService.selectPageBysql(page, queryCondition);
    }

    /**
     * 公告查看
     *
     * @return
     */
    @GetMapping("/getNoticeInfo")
    @ApiOperation(value = "查询-公告查看列表")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public IPage<Map<String, Object>> getNoticeInfo(String notificationTitle, Integer notificationType, String publishPerson, Integer urgency, String startTime, String endTime,
                                                    @RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Map<String, Object> queryCondition = new HashMap<>();
        queryCondition.put("userId", loginInfo.getUserId());
        queryCondition.put("appId", loginInfo.getAppId());
        queryCondition.put("companyCode", loginInfo.getCompanyCode());
        //queryCondition.put("dataType", loginInfo.getDataType());
        queryCondition.put("notificationTitle", notificationTitle);//标题
        queryCondition.put("notificationType", notificationType);//类别
        queryCondition.put("publishPerson", publishPerson);//发布人
        queryCondition.put("urgency", urgency);//紧急程度
        queryCondition.put("publishDate", startTime);//发布-开始时间
        queryCondition.put("publishDate2", endTime);//发布-结束时间
        queryCondition.put("userOrgId", loginInfo.getUserOrgId());//发布-结束时间
        queryCondition.put("ownerCode", loginInfo.getOwnerCode());
        Page<Map<String, Object>> page = new Page<>(currentPage, pageSize);
        return notificationService.getNoticeInfo(page, queryCondition);
    }


    /**
     * 公告查看 - 未读（pc）
     *
     * @return
     */
    @GetMapping("/getNoticeInfo/noRead")
    @ApiOperation(value = "查询-公告列表")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public List<Map<String, Object>> getNoticeInfoNoRead() {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Map<String, Object> queryCondition = new HashMap<>();
        queryCondition.put("userId", loginInfo.getUserId());
        queryCondition.put("appId", loginInfo.getAppId());
        return notificationService.getNoticeInfoNoRead(queryCondition);
    }


    /**
     * 查询-公告维护列表（厂）
     *
     * @return
     */
    @GetMapping("/getNoticeInfos")
    @ApiOperation(value = "查询-公告维护列表(车厂)")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public IPage<Map<String, Object>> getNoticeInfos(String notificationTitle, Integer notificationType,
                                                     String publishPerson, String status,
                                                     String publishDate, String publishDate2,
                                                     String startTime, String startTime2,
                                                     @RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) throws ParseException {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Map<String, Object> queryCondition = new HashMap<>();
        queryCondition.put("userId", loginInfo.getUserId());
        queryCondition.put("companyId", loginInfo.getCompanyId());
        queryCondition.put("appId", loginInfo.getAppId());
        queryCondition.put("dataType", loginInfo.getDataType());
        queryCondition.put("notificationTitle", notificationTitle);//公告标题
        queryCondition.put("notificationType", notificationType);//公告类别
        queryCondition.put("publishPerson", publishPerson);//发布人
        queryCondition.put("status", status);//状态
        queryCondition.put("publishDate", publishDate);//发布-开始时间
        queryCondition.put("publishDate2", publishDate2);//发布-结束时间
        queryCondition.put("startTime", startTime);//有效-开始时间
        queryCondition.put("startTime2", startTime2);//有效-结束时间
        Page<Map<String, Object>> page = new Page<>(currentPage, pageSize);
        return notificationService.getNoticeInfos(page, queryCondition);
    }


    /**
     * 查询-公告维护列表
     *
     * @return
     */
    @GetMapping("/getNoticeJxsInfos")
    @ApiOperation(value = "查询-公告维护列表(经销商)")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public IPage<Map<String, Object>> getNoticeJxsInfos(String notificationTitle, Integer notificationType,
                                                        String publishPerson, String status,
                                                        String publishDate, String publishDate2,
                                                        String startTime, String startTime2,
                                                        @RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) throws ParseException {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Map<String, Object> queryCondition = new HashMap<>();
        queryCondition.put("userId", loginInfo.getUserId());
        queryCondition.put("companyId", loginInfo.getCompanyId());
        queryCondition.put("companyCode", loginInfo.getCompanyCode());
        queryCondition.put("appId", loginInfo.getAppId());
        queryCondition.put("dataType", loginInfo.getDataType());
        queryCondition.put("ownerCode", loginInfo.getOwnerCode());
        queryCondition.put("notificationTitle", notificationTitle);//公告标题
        queryCondition.put("notificationType", notificationType);//公告类别
        queryCondition.put("publishPerson", publishPerson);//发布人
        queryCondition.put("STATUS", status);//状态
        queryCondition.put("publishDate", publishDate);//发布-开始时间
        queryCondition.put("publishDate2", publishDate2);//发布-结束时间
        queryCondition.put("startTime", startTime);//有效-开始时间
        queryCondition.put("startTime2", startTime2);//有效-结束时间
        Page<Map<String, Object>> page = new Page<>(currentPage, pageSize);
        return notificationService.getNoticeJxsInfos(page, queryCondition);
    }


    /**
     * 通过主键ID获取数据
     *
     * @param id 数据主键ID
     * @return Map<String, Object> 数据对应的map 结构
     * @author chengliang
     * @since 2019-09-05
     */
    @ResponseBody
    @GetMapping(value = "/{id}")
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "通过主键ID获取数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Map<String, Object> getById(@PathVariable("id") Long id) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        NotificationFeedbackDTO notificationFeedbackDTO = new NotificationFeedbackDTO();
        notificationFeedbackDTO.setStatus(CommonConstants.IS_YES);
        notificationFeedbackDTO.setNotificationId(id);
        notificationFeedbackDTO.setFeedbackUserName(loginInfo.getUserName());
        notificationFeedbackDTO.setFeedbackUser(loginInfo.getUserId());
        Integer coun = notificationFeedbackService.selectbyuid(id.intValue(), loginInfo.getUserId().intValue());
        if (coun <= 0) {
            logger.debug("notificationFeedbackDTO:{}", notificationFeedbackDTO);
            notificationFeedbackService.insert(notificationFeedbackDTO);
        }
        Map<String, Object> byId = notificationService.getById(id);
        int i = 13;
        String endTime = byId.get("endTime").toString().substring(0, i);
        String orgId = byId.get("publishOrgId").toString();
        if (!StringUtils.isNullOrEmpty(orgId)) {
            logger.info("publishOrgId Is前:{}" + orgId);
            List<OrgVO> childOrgs = orgService.getChildOrgs(orgId);
            if (childOrgs != null && !childOrgs.isEmpty()) {
                byId.put("publishOrgName", childOrgs.get(0).getText());
            }
            logger.debug("处理后：publishOrgId:{}，publishOrgName:{}", byId.get("publishOrgId"), byId.get("publishOrgName"));
        }
        byId.put("endTime", endTime);
        return byId;
    }

    /**
     * 根据id删除对象
     *
     * @param id 需要修改数据的ID
     * @author chengliang
     * @since 2019-09-05
     */
    @DeleteMapping(value = "/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "通过ID删除数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public boolean deleteById(@PathVariable("id") Long id) {
        logger.debug("删除ID:{}", id);
        Integer byId = notificationService.getByStatusId(id);
        if (byId == 0) {
            notificationService.deleteById(id);
        } else {
            throw new ServiceBizException("公告已发布不可删除");
        }
        return true;
    }

    /**
     * 进行数据修改
     *
     * @param id              需要修改数据的ID
     * @param notificationDTO 需要保存的DTO
     * @return Map<String, Object> 返回的数据map
     * @author chengliang
     * @since 2019-09-05
     */
    @ResponseBody
    @PutMapping(value = "/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "通过ID修改数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Map<String, Object> update(@PathVariable("id") Long id, @RequestBody NotificationDTO notificationDTO) {
        logger.debug("notificationDTO:{}", notificationDTO);
        notificationDTO.setIsDeleted(0);
        return notificationService.update(id, notificationDTO);
    }

    /**
     * 根据IDs批量删除对象
     *
     * @param ids 需要修改数据的ID集合
     * @author chengliang
     * @since 2019-09-05
     */
//    @DeleteMapping(value = "/batch/{ids}")
//    @ResponseStatus(HttpStatus.NO_CONTENT)
//    @ApiOperation(value = "通过IDs批量删除数据")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
//    })
//    public boolean deleteByIds(@PathVariable("ids") String ids) {
//        logger.debug("删除ID:{}", ids);
//        notificationService.deleteBatchIds(ids);
//        return true;
//    }

    /**
     * 通知通告数据新增
     *
     * @param notificationInfoDTO 需要保存的DTO
     * @return Map<String, Object> 返回的数据map
     * @author chengliang
     * @since 2019-09-05
     */
    @PostMapping(value = "/add")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "通知通告数据新增")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Integer insert(@RequestBody NotificationInfoDTO notificationInfoDTO) {
        return notificationService.insert(notificationInfoDTO);
    }


    /**
     * 通过主键ID获取通知通告详情数据
     *
     * @param id 数据主键ID
     * @return
     * @author chengliang
     * @since 2019-09-05
     */
    @ResponseBody
    @GetMapping(value = "/detail/{id}")
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "通过主键ID获取通知通告详情数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public NotificationInfoDTO getNotificationInfoById(@PathVariable("id") Integer id) {
        return notificationService.getNotificationInfoById(id);
    }

    /**
     * 进行数据修改
     *
     * @param id                  需要修改数据的ID
     * @param notificationInfoDTO 需要保存的DTO
     * @return Map<String, Object> 返回的数据map
     * @author chengliang
     * @since 2019-09-05
     */
    @ResponseBody
    @PutMapping(value = "/update/{id}")
    @ResponseStatus(HttpStatus.OK)
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "通过ID修改数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Integer updateNotification(@PathVariable("id") Integer id, @RequestBody NotificationInfoDTO notificationInfoDTO) {
        logger.debug("notificationInfoDTO:{}", notificationInfoDTO);
        return notificationService.updateNotification(id, notificationInfoDTO);
    }

    /**
     * 对通知通告进行撤回
     *
     * @param ids 需要修改数据的ID
     * @return Map<String, Object> 返回的数据map
     * @author chengliang
     * @since 2019-09-05
     */
  /*  @ResponseBody
    @PostMapping(value = "/withdraw")
    @ResponseStatus(HttpStatus.CREATED)
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "通过IDs对通知通告进行撤回")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Integer withdrawNotificationByIds(@RequestBody List<Long> ids) {
        logger.debug("ids:{}", ids);
        return notificationService.withdrawNotificationByIds(ids);
    }*/

    /**
     * 通知通告发布
     *
     * @param id                  需要修改数据的ID
     * @param notificationInfoDTO 需要保存的DTO
     * @return Map<String, Object> 返回的数据map
     * @author chengliang
     * @since 2019-09-05
     */
    @ResponseBody
    @PutMapping(value = "/publish/{id}")
    @ResponseStatus(HttpStatus.OK)
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "通知通告-发布")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Long publishNotification(@PathVariable("id") Integer id, @RequestBody NotificationInfoDTO notificationInfoDTO) {
        logger.debug("notificationInfoDTO:{}", notificationInfoDTO);
        return notificationService.publishNotification(id, notificationInfoDTO);
    }

    /**
     * 已读列表(车厂)ok
     */
    @GetMapping(value = "/getCcIsReadList/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "车厂-已读列表")
    public Page<Map<String, Object>>  getCcIsReadList(@PathVariable("id") Integer id,
                                                      @RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Page<Map<String, Object>> page = new Page<>(currentPage,pageSize);
        return notificationService.getCcIsReadList(page, id, loginInfo.getAppId(),loginInfo.getCompanyId());
    }


    /**
     * 已读列表(经销商)
     */
    @GetMapping(value = "/getCcIsReadList/dealer/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "已读列表(经销商)")
    public Page<Map<String, Object>>  getCcDealerIsReadList(@PathVariable("id") Integer id,
                                                            @RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Page<Map<String, Object>> page = new Page<>(currentPage,pageSize);
        return notificationService.getCcDealerIsReadList(page, id, loginInfo.getAppId(),loginInfo.getCompanyId());
    }


    /**
     * 车厂-未读列表（车厂）
     */
    @GetMapping(value = "/getCcNoReadList/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "车厂-未读列表（车厂）")
    public Page<Map<String, Object>> getCcNoReadList(@PathVariable("id") Integer id,
                    @RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Page<Map<String, Object>> page = new Page<>(currentPage,pageSize);
        return notificationService.getCcNoReadList(page, id, loginInfo.getAppId(),loginInfo.getCompanyId());
    }
    /**
     * 车厂-未读列表（经销商）
     */
    @GetMapping(value = "/getCcNoReadList/dealer/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "车厂-未读列表（经销商）")
    public Page<Map<String, Object>> getCcNoReadDealerList(@PathVariable("id") Integer id,
                   @RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Page<Map<String, Object>> page = new Page<>(currentPage,pageSize);
        return notificationService.getCcNoReadDealerList(page, id, loginInfo.getAppId(),loginInfo.getCompanyId());
    }

    /**
     * 未读列表（经销商）10461003 （车厂）
     */
    @GetMapping(value = "/getJxsNoReadLists/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "经销商-未读列表（车厂）")
    public List<Map<String, Object>> getJxsNoReadLists(@PathVariable("id") Integer id) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        return notificationService.getJxsNoReadList(SysAuthDictCodeConstants.DATA_TYPE_BY_SUPER, id, loginInfo.getAppId());
    }

    /**
     * 已读列表(经销商)
     */
    @GetMapping(value = "/getJxsIsReadList/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "经销商-已读列表")
    public List<Map<String, Object>> getJxsIsReadList(@PathVariable("id") Integer id) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        return notificationService.getIsReadList( id, loginInfo.getCompanyId());
    }

    /**
     * 未读列表（经销商）10461001
     */
    @GetMapping(value = "/getJxsNoReadList/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "经销商-未读列表（经销商）")
    public List<Map<String, Object>> getJxsNoReadList(@PathVariable("id") Integer id) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        return notificationService.getNoReadList(id, loginInfo.getCompanyId());
    }


    //step5 保存附件
    @ApiOperation(value = "上传文件")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @PostMapping(value = "/getFileDate")
    public RestResultResponse<String> getFileDate(String file) {
        RestResultResponse<String> upload = fileServiceClient.upload(file);
        logger.info("上传的url地址为：" + upload.getData());
        return upload;
    }


    //step2 车厂用户角色
    @ApiOperation(value = "查询-车厂用户角色")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/userRoleName")
    public IPage<RolePageVO> getUserRoleName(@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage,
                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                             @RequestParam(value = "roleCode" , required = false) String roleCode,
                                             @RequestParam(value = "roleName", required = false) String roleName) {
        Page<RolePageVO> page = new Page(currentPage, pageSize);
        LoginInfoDto loginInfoDto = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Map<String, Object> queryCondition = new HashMap<>();
        //10461003 - 车厂
        queryCondition.put("dataType", 10461003);
        queryCondition.put("appId", loginInfoDto.getAppId());
        queryCondition.put("roleCode", roleCode);
        queryCondition.put("roleName", roleName);
        queryCondition.put("companyId", loginInfoDto.getCompanyId());
        return roleService.getUserRoleName(page, queryCondition);
    }

    /**
     * 查询-下发经销商
     * 2019-10-29 adu
     */
    @ApiOperation(value = "查询-下发经销商（模糊查询）")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/getDealerInfos")
    public IPage<Map<String, Object>> getDealerInfos(@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage,
                                                     @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, String dealerCode, String dealerName) {
        Page<RolePageVO> page = new Page(currentPage, pageSize);
        LoginInfoDto loginInfoDto = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        Map<String, Object> queryCondition = new HashMap<>();
        queryCondition.put("appId", loginInfoDto.getAppId());
        queryCondition.put("saleArea", dealerCode);
        queryCondition.put("dealerName", dealerName);
        return dealerChannelService.getDealerInfos(page, queryCondition);
    }

    @PostMapping(value = "/publishIM")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "IM通知接口")
    public String publishnotificationim(@RequestBody TextNotifyDto textNotifyDto) {
        logger.debug("通知内容:{}", textNotifyDto);
        return notificationService.publishNotificationIm(textNotifyDto);
    }

    /**
     * 新增通知公告
     * 2019-12-18 李贺
     */
    @ApiOperation(value = "新增通知公告")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @PostMapping("/addNotification")
    public void addNotification(@RequestBody AddNotificationVO addNotificationVO) {
        notificationService.addNotification(addNotificationVO);
    }
}